package com.stalltea.jdk8.lambda.function;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.Arrays;
import java.util.List;
import java.util.function.Predicate;

/**
 * @author yivlchangfa
 * @since 2021/9/1 12:33
 */
public class Jdk8Function {

    public static String processFile(BufferReaderProcessor processor) throws IOException {
        try (BufferedReader bufferedReader = new BufferedReader(new FileReader("f:/text.txt"))) {
            return processor.process(bufferedReader);
        }
    }

    public static void main(String[] args) {

        List<String> str = Arrays.asList("a", "b", "A", "B");
        str.sort((s1, s2) -> s1.compareToIgnoreCase(s2));

        try {
            System.out.println(processFile(BufferedReader::readLine));
        } catch (Exception e) {
            e.printStackTrace();
        }

        IntPredicate evenNumbers = (int i) -> i % 2 == 0;
        evenNumbers.test(1000);

        Predicate<Integer> oddNumbers = (Integer i) -> i % 2 == 1;
        oddNumbers.test(1000);

        Integer i = 0;
        IntPredicate t = val -> {
            System.out.println(i);
            return true;
        };
        MethodRe methodRe = String::substring;
    }

    public interface IntPredicate {

        boolean test(int t);
    }

    public interface MethodRe {

        String test(String str, int i);
    }

    class Testt {
        //        public String  tt(MethodRe methodRe){
        //            return methodRe.test();
        //        };
    }

}
